package com.mengtian_tech.tju.dataquery.api.controller;

import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mengtian_tech.tju.dataquery.api.model.QueryType;
import com.mengtian_tech.tju.dataquery.api.service.AIChatService;
import com.mengtian_tech.tju.dataquery.api.service.QueryLogService;
import com.mengtian_tech.tju.dataquery.api.util.ResponseUtil;
import com.mengtian_tech.tju.dataquery.api.vo.SendAIMsg;

/**
 * 查询控制器
 * @author wxd56
 *
 */
@RestController
@RequestMapping("/api/query_ai")
public class AIQueryController {
	 
	@Autowired
	QueryLogService queryLogService;
 
	
	/**
	 * 首页综合查询
	 * @param key
	 * @param pageNo
	 */
	@PostMapping("send")
	public Object queryAll(
			@RequestBody SendAIMsg msg,
			HttpServletRequest req) throws ParseException {

		String result = AIChatService.sendMsg(msg.getMsg());
		
		
		//记录日志
		this.queryLogService.addLog(req.getRemoteUser(),QueryType.AI_QUERY, msg.getMsg(),result);
		
		 
		
		return ResponseUtil.ok(result);
		
	}
	
	
}
